$(function () {

    $("body").on("click",'#saveConfig',function () {
        saveConfig();
    }).on("change",'.onoffswitch',function(event){
        var _check = event.target.checked;
        if (!_check){
            $('.refundTime').addClass('hide');
        }
        if (_check){
            $('.refundTime').removeClass('hide');
        }
    });

    /**
     * 保存配置信息
     */
    function saveConfig() {
        var params = $("#sysConfigForm").serializeJSON();
        params = JSON.stringify(params);
        $.ajax({
            url: baseloaction + '/admin/manage/config/saveConfig',
            type:"post",
            dataType:'json',
            data:params,
            contentType:'application/json;charset=utf-8',
            success:function (result) {
                if(result.success==true){
                    icModale(0, result.message);
                    window.location.href= baseloaction + '/admin/qa/question/queryQaConfig'
                }else{
                    icModale(0, result.message);
                }
            },
            error:function (error) {
                icModale(0, "系统错误，配置数据保存失败");
            }
        });
    }

});

